package entities;

import gfx.Image;

import javax.microedition.khronos.opengles.GL10;

import util.GameVars;
import util.Logger;

public class Player {
	Image spriteImage;

	float y;
	
	short lane;
	short nextLane;
		
	private boolean isDead;

	public Player(){
		isDead = false;
		
		y = 3.75f;
		
		spriteImage = new Image(GameVars.TEXTURE_PLAYER, 1, 1);
		
		nextLane = 3;
	}
	
	public void update(long time){
		if(lane != nextLane);
			lane = nextLane;
	}
	
	// To be handled on handleUp()
	public void move(boolean right){
		nextLane = right ? lane >= GameVars.LANE_COUNT ? 5 : ++lane : lane <= 1 ? 1 : --lane;
	}
	
	public void draw(GL10 gl){
		spriteImage.draw(gl, lane, y);
	}
	
	public void handleDeath(){
		isDead = true;
	}
	
	public boolean isDead(){ return isDead; }

	public float getY(){ return y; }
	public float getHeight(){ return spriteImage.getHeight(); }
	public short getLane(){ return lane; }
}
